package com.miniapp.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.miniapp.entity.enums.MiniProductPayStatus;
import com.miniapp.entity.enums.MiniVersionStatus;
import com.miniapp.utils.DateUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 用户产品
 * 
 * @author linyuchi
 * @email xunli-03@163.com
 * @date 2018-04-14 16:44:39
 */
@SuppressWarnings("serial")
@TableName("mini_user_product")
public class MiniUserProductEntity extends BaseEntity{

	/**
     * 接入状态
     */
	private MiniVersionStatus status;
	
	/**
     * 购买时间
     */
	private Date buyTime;
	
	/**
     * 版本
     */
	private String edition;
	
	/**
     * 过期时间
     */
	private Date expirationTime;
	


	/**
	 * 产品名称
	 */
	private Long productId;
	
	/**
     * 所属用户
     */
	private Long buyUserId;


	/**
	 * 系统用户
	 */
	@TableField(exist = false)
	private MiniUserEntity miniUser;
	
	/**
     * 支付状态
     */
	private MiniProductPayStatus payStatus;
	
	/**
     * appid
     */
	private String appid;
	


	/**
	 * 名称
	 */
	private String name;

	/**
	 * 套餐
	 */
	private Long productPriceId;



	/**
	 * 微信appID
	 */
	private String wxAppid;

	/**
	 * 微信原始ID
	 */
	private String wxGhId;
	/**
	 * 累计消费
	 * @return
	 */
	private BigDecimal addMoney;


	/**
	 * 产品名称
	 */
	@TableField(exist = false)
	private String productName;

	/**
	 * 产品编码
	 */
	@TableField(exist = false)
	private String productCode;

	/**
	 * 产品价格版本
	 */
	@TableField(exist = false)
	private String priceType;

	/**
	 * 模版编码
	 */
	private String wxTmpId;
	/**
	 * 剩余天数
	 * @return
	 */
	@TableField(exist = false)
	private Integer remindDay;

	/**
	 * 新版本
	 */

	@TableField(exist = false)
	private Integer newVersion;

	public Integer getNewVersion() {
		return newVersion;
	}

	public void setNewVersion(Integer newVersion) {
		this.newVersion = newVersion;
	}

	public String getWxTmpId() {
		return wxTmpId;
	}

	public void setWxTmpId(String wxTmpId) {
		this.wxTmpId = wxTmpId;
	}

	public String getPriceType() {
		return priceType;
	}

	public void setPriceType(String priceType) {
		this.priceType = priceType;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	public MiniVersionStatus getStatus() {
		return status;
	}

	public void setStatus(MiniVersionStatus status) {
		this.status = status;
	}

	public Date getBuyTime() {
		return buyTime;
	}

	public void setBuyTime(Date buyTime) {
		this.buyTime = buyTime;
	}

	public String getEdition() {
		return edition;
	}

	public void setEdition(String edition) {
		this.edition = edition;
	}

	public Date getExpirationTime() {
		return expirationTime;
	}

	public void setExpirationTime(Date expirationTime) {
		this.expirationTime = expirationTime;
	}

	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public Long getBuyUserId() {
		return buyUserId;
	}

	public void setBuyUserId(Long buyUserId) {
		this.buyUserId = buyUserId;
	}

	public MiniUserEntity getMiniUser() {
		return miniUser;
	}

	public void setMiniUser(MiniUserEntity miniUser) {
		this.miniUser = miniUser;
	}

	public MiniProductPayStatus getPayStatus() {
		return payStatus;
	}

	public void setPayStatus(MiniProductPayStatus payStatus) {
		this.payStatus = payStatus;
	}

	public String getAppid() {
		return appid;
	}

	public void setAppid(String appid) {
		this.appid = appid;
	}


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getProductPriceId() {
		return productPriceId;
	}

	public void setProductPriceId(Long productPriceId) {
		this.productPriceId = productPriceId;
	}


	public String getWxAppid() {
		return wxAppid;
	}

	public void setWxAppid(String wxAppid) {
		this.wxAppid = wxAppid;
	}

	public String getWxGhId() {
		return wxGhId;
	}

	public void setWxGhId(String wxGhId) {
		this.wxGhId = wxGhId;
	}


	public BigDecimal getAddMoney() {
		return addMoney;
	}

	public void setAddMoney(BigDecimal addMoney) {
		this.addMoney = addMoney;
	}

	public int getRemindDay() {
		Date today = new Date();
		int day = DateUtils.getTimeDistance(today,this.expirationTime);
		if(day < 0){
			day = 0;
		}
		return day;
	}

	public void setRemindDay(int remindDay) {
		this.remindDay = remindDay;
	}

}
